<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/8/27/027
 * Time: 16:38
 */

namespace App\Http\Controllers\Admin;

use App\Http\Service\Admin\AdminService;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Session;
use Config;

class IndexController extends Controller
{
    public function accman()
    {
        return view("Index.accman");
    }

    /**
     * @param Request $request
     * @return bool|mixed|string
     * 账号列表
     */
    public function getAdminList(Request $request)
    {
        $where = $request->except('_token');
        $where['token'] = Session::get(config::get('custom.setting.MEMBER_TOKEN'));
        $agent = new AdminService();
        $data = $agent->getAdminList($where);
        return $data;
    }

    /**
     * @param Request $request
     * @return bool|mixed|string
     * 添加管理员账号
     */
    public function addAdminAccount(Request $request)
    {
        $where = $request->except('_token');
        $where['token'] = Session::get(config::get('custom.setting.MEMBER_TOKEN'));
        $agent = new AdminService();
        $data = $agent->doAdminAdd($where);
        return $data;
    }

    /**
     * @param Request $request
     * @return bool|mixed|string
     * 编辑管理员账号
     */
    public function updateAdminAccount(Request $request)
    {
        $where = $request->except('_token');
        $where['token'] = Session::get(config::get('custom.setting.MEMBER_TOKEN'));
        $agent = new AdminService();
        $data = $agent->doAdminUpdate($where);
        return $data;
    }

    /**
     * @param Request $request
     * @return bool|mixed|string
     * 删除管理员账号
     */
    public function deleteAdminAccount(Request $request)
    {
        $where = $request->except('_token');
        $where['token'] = Session::get(config::get('custom.setting.MEMBER_TOKEN'));
        $agent = new AdminService();
        $data = $agent->doAdmindelete($where);
        return $data;
    }


    /**
     * @param Request $request
     * @return bool|mixed|string
     * 操作日志
     */
    public function getOpLogList(Request $request)
    {
        $where = $request->except('_token');
        $where['token'] = Session::get(config::get('custom.setting.MEMBER_TOKEN'));
        $agent = new AdminService();
        $data = $agent->getOpLogList($where);
        return $data;
    }
}